package ds;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashMap;

public class WordMap {
	private HashMap<String, String> dictionary;
	
	public WordMap(){
		dictionary = new HashMap<String, String>();
	}
	
	public WordMap(String keywordFile) {
		dictionary = new HashMap<String, String>();
		try {
			BufferedReader reader = new BufferedReader(new FileReader(keywordFile));
			String sentence = "";
			while((sentence = reader.readLine()) != null){
				String[] words = sentence.split("\t");
				String key = words[0].toLowerCase();
				if(!dictionary.containsKey(key)){
					String value = words[1].toLowerCase();
					dictionary.put(key, value);		
				}
			}	
			reader.close();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public String getMapWord(String word) {
		return dictionary.containsKey(word)? dictionary.get(word) : "";
	}
}
